package com.wytec.xywzxw.controller;

import com.wytec.xywzxw.bean.AccessLog;
import com.wytec.xywzxw.bean.commonBean.CommonResult;
import com.wytec.xywzxw.bean.commonBean.PageSizeBean;
import com.wytec.xywzxw.service.AccessLogService;
import com.wytec.xywzxw.utils.CommonUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "访问日志模块")
public class LogController extends BaseApiController{
    @Resource
    AccessLogService logService;
    @RequestMapping("/log/qry")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码 默认1"),
            @ApiImplicitParam(name = "size", value = "每页数据量 默认10")
    })
    @ApiOperation("获取访问日志列表")
    public CommonResult<Object> log(PageSizeBean page) {
        List<AccessLog> accessLogList = logService.getAccessLogList(page);
        Map<String, Object> pageDataMap = CommonUtils.createPageDataMap(accessLogList);
        return CommonResult.success(pageDataMap);
    }
}